import service from '@/utils/request'

export const getRoleApiUrl = (name:string)=>{
	if(name=='page'){
		return '/sys/role/list';
	}else if(name=='delete'){
		return '/sys/role/del';
	}
	return "";
}

export const useRoleMenuApi = () => {
	return service.get('/sys/role/menu')
}

export const useRoleApi = (id: number) => {
	return service.get('/sys/role/get?ids=' + id)
}

export const useRoleListApi = () => {
	return service.get('/sys/role/selectpage')
}

export const useRoleSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.post('/sys/role/edit', dataForm)
	} else {
		return service.post('/sys/role/add', dataForm)
	}
}

export const useRoleDataScopeSubmitApi = (dataForm: any) => {
	return service.post('/sys/role/data-scope', dataForm)
}

export const useRoleUserSubmitApi = (roleId: number, dataForm: any) => {
	return service.post('/sys/role/user/' + roleId, dataForm)
}
